package 笔试.四4399;

import java.util.Arrays;
import java.util.Scanner;

public class 循环打家劫舍 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String numstr = sc.nextLine();
        String[] strs = numstr.split(" ");
        int[] nums = new int[strs.length];
        for (int i = 0; i < nums.length; i++) {
            nums[i] = Integer.parseInt(strs[i]);
        }
        Solution solution = new Solution();
        int res = solution.rob(nums);
        System.out.println(res);
    }

    static class Solution {
        public int rob(int[] nums) {
            int len = nums.length;
            int[] dp = new int[len + 2];
            for (int i = 2; i < len + 2; i++) {
                dp[i] = Math.max(dp[i - 2] + nums[i - 2], dp[i - 1]);
            }
            System.out.println(Arrays.toString(dp));
            return dp[len + 1];
        }
    }

}